package com.jiaai.shop.store.mapper;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.jiaai.shop.store.entity.SExtractMoney;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.jiaai.shop.store.entity.SearchExtractVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * <p>
  * 提现申请表 Mapper 接口
 * </p>
 *
 * @author
 * @since 2018-04-01
 */
@Mapper
public interface SExtractMoneyMapper extends BaseMapper<SExtractMoney> {
    /**
     * 搜索申请提现信息
     * @param page
     * @param search
     * @return
     */
    List<Map<String,Object>> list(Page page,@Param("search") SearchExtractVo extractVo);
    /**
     * 后台处理提现状态更新
     * */
    @Update("UPDATE s_extract_money \n" +
            "SET state=#{state},results=#{results},resultsTime=NOW() \n" +
            "WHERE id=#{id}")
    boolean updateExtract(@Param("state") Integer state,@Param("results") Integer results,@Param("mId") String mId,@Param("id") Integer id);

    /**
     * 同意提现后，用户积分扣除
     *
     * */
    @Update("UPDATE s_member \n" +
            "SET total_score=total_score-#{inter} \n" +
            "WHERE memberId=#{mId}")
    boolean updateMidScore(@Param("mId") String mId,@Param("inter") int inter);
    /**
     * 搜索提现金额
     */
    @Select("SELECT extractNumber \n" +
            "FROM s_extract_money \n" +
            "WHERE id=#{id}")
    int seachInter(@Param("id")int id);




}